package c2b

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/c2b"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// QrcodePayPreAuthService 二维码支付预授权服务
type QrcodePayPreAuthService struct {
	*services.BaseService
}

// NewQrcodePayPreAuthService 创建二维码支付预授权服务
func NewQrcodePayPreAuthService(config *core.Config) *QrcodePayPreAuthService {
	return &QrcodePayPreAuthService{
		BaseService: services.NewBaseService(config),
	}
}

// QrcodePayPreAuth 二维码支付预授权
func (s *QrcodePayPreAuthService) QrcodePayPreAuth(request *c2b.QrcodePayPreAuthRequest) (*c2b.QrcodePayPreAuthResponse, error) {
	response := c2b.NewQrcodePayPreAuthResponse()
	err := s.Post(request, response, "/open/trans/qrcodepaypreauth")
	if err != nil {
		return nil, err
	}
	return response, nil
}
